package com.insleton.admin.user.model;

import java.util.List;

public class Reply<T> {
    // 这个标识请求是正确的，前端使用了200
    private int code = 1;
    private String message;
    private String id;
    private Integer total;
    private T data;
    private List<T> dataList;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public List<T> getDataList() {
        return dataList;
    }

    public void setDataList(List<T> dataList) {
        this.dataList = dataList;
    }

    public static <T> Reply<T> success(String message) {
        Reply<T> reply = new Reply<>();
        reply.setMessage(message);
        return reply;
    }

    public static <T> Reply<T> success(String message, T data) {
        Reply<T> reply = new Reply<>();
        reply.setMessage(message);
        reply.setData(data);
        return reply;
    }

    public static <T> Reply<T> success(int code, String message, T data) {
        Reply<T> reply = new Reply<>();
        reply.setCode(code);
        reply.setMessage(message);
        reply.setData(data);
        return reply;
    }

    public static <T> Reply<T> error(String message) {
        Reply<T> reply = new Reply<>();
        reply.setMessage(message);
        return reply;
    }

    public static <T> Reply<T> error(String message, T data) {
        Reply<T> reply = new Reply<>();
        reply.setMessage(message);
        reply.setData(data);
        return reply;
    }

    public static <T> Reply<T> error(int code, String message, T data) {
        Reply<T> reply = new Reply<>();
        reply.setCode(code);
        reply.setMessage(message);
        reply.setData(data);
        return reply;
    }
}
